package com.coder.shop.rpc.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.coder.common.annotation.BaseService;
import com.coder.common.base.BaseServiceImpl;
import com.coder.shop.dao.mapper.ShopGoodsMapper;
import com.coder.shop.dao.mapper.ShopGoodsPrictureMapper;
import com.coder.shop.dao.model.ShopGoods;
import com.coder.shop.dao.model.ShopGoodsExample;
import com.coder.shop.dao.model.ShopGoodsPricture;
import com.coder.shop.rpc.api.ShopGoodsService;

/**
* ShopGoodsService实现
* @Author liuzhimin
* @Date Created by liuzhimin on 2018/4/24.
* @Description
*/
@Service
@Transactional
@BaseService
public class ShopGoodsServiceImpl extends BaseServiceImpl<ShopGoodsMapper, ShopGoods, ShopGoodsExample> implements ShopGoodsService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ShopGoodsServiceImpl.class);

    @Autowired
    ShopGoodsMapper shopGoodsMapper;
    
    @Autowired
    ShopGoodsPrictureMapper shopGoodsPrictureMapper;

    @Transactional
	@Override
	public int insertGoods(ShopGoods shopGoods, List<String> fileId) {
		
		int count = insertSelective(shopGoods);
		
		if(fileId!=null && fileId.size()>0) {
			for(String path : fileId) {
				ShopGoodsPricture p = new ShopGoodsPricture();
				p.setGoodsId(shopGoods.getId());
				p.setPath(path);
				shopGoodsPrictureMapper.insert(p);
			}
		}
		
		return count;
	}

}